using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.Drawing;
using System.ComponentModel;
using System.Drawing.Printing;
using System.Collections;
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;
using Microsoft.VisualBasic;
using Microsoft.VisualBasic.CompilerServices;
using System.IO;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;

namespace Calcio
{
    public class frmMain : System.Windows.Forms.Form
    {
        // Fields
        private Button _Button1;
        private Button _Button10;
        private Button _Button11;
        private Button _Button12;
        private Button _Button13;
        private Button _Button14;
        private Button _Button15;
        private Button _Button16;
        private Button _Button17;
        private Button _Button18;
        private Button _Button19;
        private Button _Button2;
        private Button _Button20;
        private Button _Button21;
        private Button _Button22;
        private Button _Button23;
        private Button _Button24;
        private Button _Button25;
        private Button _Button26;
        private Button _Button27;
        private Button _Button28;
        private Button _Button29;
        private Button _Button3;
        private Button _Button30;
        private Button _Button31;
        private Button _Button32;
        private Button _Button4;
        private Button _Button5;
        private Button _Button6;
        private Button _Button7;
        private Button _Button8;
        private Button _Button9;
        private Label _Label1;
        private Label _Label2;
        private Label _Label3;
        private Label _Label4;
        private Label _Label6;
        private ListBox _ListBox1;
        private Panel _Panel1;
        private PrintPreviewDialog _PrintPreviewDialog1;
        private SaveFileDialog _SaveFileDialog1;
        private TextBox _TextBox1;
        private bool anteprimaStampa;
        private int clik_linea;
        private const float cmXin = 0.0254f;
        private Color colorePenna;
        private IContainer components;
        private long contator;
        private Graphics gPoly;
        private const int HORZSIZE = 4;
        private int ind_ob;
        private int ind_og;
        private int ind_or;
        private int ind_ost;
        private bool linea;
        private myLinea[] memLinee;
        private myPolyLinea[] memPolyLinee;
        private string nomeSfondo;
        private float[] oldPolyPoint;
        private bool[] pbSelezionate;
        private bool[] pbSelezionateApp;
        private int pbX;
        private int pbY;
        private Pen PennaPoly;
        private const int PHYSICALHEIGHT = 0x6f;
        private const int PHYSICALOFFSETX = 0x70;
        private const int PHYSICALOFFSETY = 0x71;
        private const int PHYSICALWIDTH = 110;
        private float[] pointLinea1;
        private float[] pointLinea2;
        private bool polyLinea;
        private bool polyMouseDown;
        private bool presoPB;
        private PrintDocument print_document;
        private float[] pStartPoly;
        private bool stampa;
        private bool startPoly;
        private int tipoImg;
        private string tipoLinea;
        private const int VERTSIZE = 6;
        private bool xOy;

        // Methods
        public frmMain()
        {
            base.Load += new EventHandler(this.Form1_Load);
            this.presoPB = false;
            this.pbY = 0;
            this.pbX = 0;
            this.pbSelezionate = new bool[1];
            this.pbSelezionateApp = new bool[1];
            this.linea = false;
            this.clik_linea = 1;
            this.pointLinea1 = new float[2];
            this.pointLinea2 = new float[2];
            this.pStartPoly = new float[2];
            this.startPoly = false;
            this.polyLinea = false;
            this.polyMouseDown = false;
            this.oldPolyPoint = new float[2];
            this.PennaPoly = new Pen(Color.Black, 1f);
            this.nomeSfondo = "";
            this.xOy = true;
            this.tipoImg = 1;
            this.ind_ob = 1;
            this.ind_or = 1;
            this.ind_og = 1;
            this.ind_ost = 1;
            this.anteprimaStampa = false;
            this.stampa = false;
            this.print_document = new PrintDocument();
            this.contator = 0L;
            this.memLinee = new myLinea[1];
            this.memPolyLinee = new myPolyLinea[1];
            this.InitializeComponent();
        }

        [DllImport("gdi32.dll", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
        private static extern bool BitBlt(IntPtr hdcDest, int x, int y, int Width, int Height, IntPtr hdcSrc, int XSrc, int YSrc, int dwRop);
        private void Button1_Click(object sender, EventArgs e)
        {
            if (this.tipoImg == 1)
            {
                this.inserisciOggetto("birillo", 0, 0);
            }
            else
            {
                this.inserisciOggetto("birillo1", 0, 0);
            }
        }

        private void Button10_Click(object sender, EventArgs e)
        {
            this.nomeSfondo = "campo.gif";
            this.insSfondo();
        }

        private void Button11_Click(object sender, EventArgs e)
        {
            this.nomeSfondo = "1-2campo.gif";
            this.insSfondo();
        }

        private void Button12_Click(object sender, EventArgs e)
        {
            this.nomeSfondo = "area.gif";
            this.insSfondo();
        }

        private void Button13_Click(object sender, EventArgs e)
        {
            this.nomeSfondo = "centrocampo.gif";
            this.insSfondo();
        }

        private void Button14_Click(object sender, EventArgs e)
        {
            this.nomeSfondo = "verde.gif";
            this.insSfondo();
        }

        private void Button15_Click(object sender, EventArgs e)
        {
            this.tipoLinea = "solid";
            this.linea = true;
            this.colorePenna = Color.Black;
            this.Panel1.Cursor = Cursors.Cross;
        }

        private void Button16_Click(object sender, EventArgs e)
        {
            this.tipoLinea = "dash";
            this.linea = true;
            this.colorePenna = Color.Red;
            this.Panel1.Cursor = Cursors.Cross;
        }

        private void Button17_Click(object sender, EventArgs e)
        {
            //frmPrint print = new frmPrint();
            //MyProject.Forms.frmPrint.Show();
        }

        private void Button18_Click(object sender, EventArgs e)
        {
            SaveFileDialog dialog = new SaveFileDialog();
            Bitmap image = new Bitmap(this.Panel1.Width, this.Panel1.Height);
            Graphics graphics = Graphics.FromImage(image);
            IntPtr windowDC = GetWindowDC(this.Panel1.Handle);
            IntPtr hdc = graphics.GetHdc();
            BitBlt(hdc, 0, 0, this.Panel1.Size.Width, this.Panel1.Size.Height, windowDC, 0, 0, 0xcc0020);
            ReleaseDC(this.Panel1.Handle, windowDC);
            graphics.ReleaseHdc(hdc);
            graphics.Dispose();
            string str2 = Interaction.InputBox("Nome dell'esercitazione", "Nuova esercitazione", "", -1, -1);
            if (str2 == "")
            {
                Interaction.MsgBox("Esercitazione non salvata: nome non valido", MsgBoxStyle.Critical, "Attenzione");
            }
            else
            {
                IEnumerator enumerator = null;
                int num5 = this.ListBox1.Items.Count - 1;
                for (int i = 0; i <= num5; i++)
                {
                    if (Operators.ConditionalCompareObjectEqual(str2, this.ListBox1.Items[i], false) && (Interaction.MsgBox("Esercitazione esistente: sovrascrivere?", MsgBoxStyle.YesNo, "Attenzione!") == MsgBoxResult.No))
                    {
                        return;
                    }
                }
                
                modFunction.imgPrn = modFunction.GetPath() + @"\Esercitazioni\" + str2 + ".jpg";
                image.Save(modFunction.imgPrn, ImageFormat.Jpeg);
                string str = "";
                str = str + "tit:" + str2 + "@#@";
                try
                {
                    enumerator = this.Panel1.Controls.GetEnumerator();
                    while (enumerator.MoveNext())
                    {
                        Control current = (Control)enumerator.Current;
                        if (current.Name == "testo")
                        {
                            str = str + "txt:" + current.Text + "-" + Conversions.ToString(current.Location.X) + "," + Conversions.ToString(current.Location.Y) + "@#@";
                        }
                        else
                        {
                            str = str + "ogg:" + current.Name + "-" + Conversions.ToString(current.Location.X) + "," + Conversions.ToString(current.Location.Y) + "@#@";
                        }
                    }
                }
                finally
                {
                    if (enumerator is IDisposable)
                    {
                        (enumerator as IDisposable).Dispose();
                    }
                }
                str = str + "sfo:" + this.nomeSfondo + "@#@";
                float[] numArray3 = new float[2];
                long num6 = Information.UBound(this.memPolyLinee, 1);
                long num2 = 0L;
                while (num2 <= num6)
                {
                    if (this.memPolyLinee[(int)num2].x[0] != 0f)
                    {
                        str = str + "pol:";
                        long num7 = Information.UBound(this.memPolyLinee[(int)num2].x, 1);
                        for (long j = 0L; j <= num7; j += 1L)
                        {
                            str = str + Conversions.ToString(this.memPolyLinee[(int)num2].x[(int)j]) + "," + Conversions.ToString(this.memPolyLinee[(int)num2].y[(int)j]) + ",";
                        }
                        str = Strings.Left(str, Strings.Len(str) - 1) + "@#@";
                    }
                    num2 += 1L;
                }
                float[] numArray = new float[2];
                float[] numArray2 = new float[2];
                long num8 = Information.UBound(this.memLinee, 1);
                for (num2 = 0L; num2 <= num8; num2 += 1L)
                {
                    if (this.memLinee[(int)num2].x1 != 0)
                    {
                        str = str + "lin:";
                        str = str + this.memLinee[(int)num2].tipoTrattoLinea + "," + Conversions.ToString(this.memLinee[(int)num2].x1) + "," + Conversions.ToString(this.memLinee[(int)num2].y1) + "," + Conversions.ToString(this.memLinee[(int)num2].x2) + "," + Conversions.ToString(this.memLinee[(int)num2].y2) + "@#@";
                    }
                }
                str = (str + "des:" + this.TextBox1.Text + "@#@") + "dat:" + Conversions.ToString(DateTime.Now);
                StreamWriter writer = new StreamWriter(modFunction.GetPath() + @"\Esercitazioni\" + str2 + ".ese");
                writer.WriteLine(str);
                writer.Close();
                this.Label4.Text = str2;
                modFunction.caricaEserc(this.ListBox1);
                modFunction.eseTitolo = this.Label4.Text;
                modFunction.eseDesc = this.TextBox1.Text;
            }
        }

        private void Button19_Click(object sender, EventArgs e)
        {
            this.SalvaPannello(this.Panel1, "");
        }

        private void Button2_Click(object sender, EventArgs e)
        {
            int num2 = this.pbSelezionate.Length - 1;
            for (int i = this.pbSelezionate.Length - 1; i >= 0; i += -1)
            {
                if (this.pbSelezionate[i])
                {
                    this.Panel1.Controls.RemoveAt(i);
                    if (i == num2)
                    {
                        this.pbSelezionate.CopyTo(this.pbSelezionateApp, 0);
                        this.pbSelezionate = new bool[i + 1];
                        this.pbSelezionateApp.CopyTo(this.pbSelezionate, 0);
                        this.pbSelezionateApp = new bool[i + 1];
                    }
                    else
                    {
                        this.pbSelezionate[i] = false;
                        num2--;
                    }
                }
            }
        }

        private void Button20_Click(object sender, EventArgs e)
        {
            this.pulisciPanel();
            this.TextBox1.Text = "";
        }

        private void Button21_Click(object sender, EventArgs e)
        {
            this.nomeSfondo = "";
            this.Panel1.BackgroundImage = null;
        }

        private void Button22_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void Button23_Click(object sender, EventArgs e)
        {
            if (this.tipoImg == 1)
            {
                this.Button6.Image = Image.FromFile(modFunction.GetPath() + @"\Img\ob" + Conversions.ToString(this.ind_ob) + ".gif");
                this.Button7.Image = Image.FromFile(modFunction.GetPath() + @"\Img\og" + Conversions.ToString(this.ind_og) + ".gif");
                this.Button4.Image = Image.FromFile(modFunction.GetPath() + @"\Img\or" + Conversions.ToString(this.ind_or) + ".gif");
                this.Button5.Image = Image.FromFile(modFunction.GetPath() + @"\Img\ostacolo" + Conversions.ToString(this.ind_ost) + "a.gif");
                this.Button3.Image = Image.FromFile(modFunction.GetPath() + @"\Img\paletto1.gif");
                this.Button1.Image = Image.FromFile(modFunction.GetPath() + @"\Img\birillo1.gif");
                this.Button9.Image = Image.FromFile(modFunction.GetPath() + @"\Img\cinesino1.gif");
                this.tipoImg = 2;
            }
            else if (this.tipoImg == 2)
            {
                this.Button6.Image = Image.FromFile(modFunction.GetPath() + @"\Img\omino_b.gif");
                this.Button7.Image = Image.FromFile(modFunction.GetPath() + @"\Img\omino_g.gif");
                this.Button4.Image = Image.FromFile(modFunction.GetPath() + @"\Img\omino_r.gif");
                this.Button5.Image = Image.FromFile(modFunction.GetPath() + @"\Img\ostacolo.gif");
                this.Button3.Image = Image.FromFile(modFunction.GetPath() + @"\Img\paletto.gif");
                this.Button1.Image = Image.FromFile(modFunction.GetPath() + @"\Img\birillo_ico.gif");
                this.Button9.Image = Image.FromFile(modFunction.GetPath() + @"\Img\cinesino.gif");
                this.tipoImg = 1;
            }
        }

        private void Button24_Click(object sender, EventArgs e)
        {
            this.inserisciTesto("", 0, 0);
        }

        private void Button25_Click(object sender, EventArgs e)
        {
            this.polyLinea = true;
            this.startPoly = true;
            this.Panel1.Cursor = Cursors.Cross;
        }

        private void Button26_Click(object sender, EventArgs e)
        {
            if (this.Label4.Text == "Nuova")
            {
                Interaction.MsgBox("Salvare l'esercitazione prima di fare l'upload", MsgBoxStyle.Critical, "Attenzione!");
            }
            else
            {
                string folderPath = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
                Directory.CreateDirectory(folderPath + @"\" + this.Label4.Text);
                folderPath = folderPath + @"\" + this.Label4.Text;
                modFunction.imgPrn = folderPath + @"\" + this.Label4.Text + ".jpg";
                modFunction.saveImgTmp(this.Panel1, modFunction.imgPrn);
                modFunction.creaMyXML(folderPath);
            }
        }

        private void Button27_Click(object sender, EventArgs e)
        {
            if (Interaction.MsgBox("Devi essere connesso ad internet per poter fare l'upload.\n\rSe non sei connesso clicca su Annulla altrimenti su OK", MsgBoxStyle.OkCancel, "Attenzione!") != MsgBoxResult.Cancel)
            {
                //new frmLogin().Show();
            }
        }

        private void Button28_Click(object sender, EventArgs e)
        {
            try
            {
                if (Information.UBound(this.memPolyLinee, 1) == 0)
                {
                    this.memPolyLinee[0].x = new float[1];
                    this.memPolyLinee[0].y = new float[1];
                }
                else
                {
                    this.memPolyLinee = (myPolyLinea[])Utils.CopyArray((Array)this.memPolyLinee, new myPolyLinea[(Information.UBound(this.memPolyLinee, 1) - 1) + 1]);
                }
                this.Panel1.Visible = false;
                this.Panel1.Visible = true;
                this.printLineaOnForm();
                this.printPolyLineaOnForm();
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                ProjectData.ClearProjectError();
            }
        }

        private void Button29_Click(object sender, EventArgs e)
        {
            try
            {
                if (Information.UBound(this.memLinee, 1) == 0)
                {
                    int index = 0;
                    this.memLinee[index].tipoTrattoLinea = "";
                    this.memLinee[index].x1 = 0;
                    this.memLinee[index].x2 = 0;
                    this.memLinee[index].y1 = 0;
                    this.memLinee[index].y2 = 0;
                }
                else
                {
                    this.memLinee = (myLinea[])Utils.CopyArray((Array)this.memLinee, new myLinea[(Information.UBound(this.memLinee, 1) - 1) + 1]);
                }
                this.Panel1.Visible = false;
                this.Panel1.Visible = true;
                this.printLineaOnForm();
                this.printPolyLineaOnForm();
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                ProjectData.ClearProjectError();
            }
        }

        private void Button3_Click(object sender, EventArgs e)
        {
            if (this.tipoImg == 1)
            {
                this.inserisciOggetto("paletto", 0, 0);
            }
            else
            {
                this.inserisciOggetto("paletto1", 0, 0);
            }
        }

        private void Button30_Click(object sender, EventArgs e)
        {
            //about about = new about();
            //MyProject.Forms.about.Show();
        }

        private void Button31_Click(object sender, EventArgs e)
        {
            modFunction.imgPrn = modFunction.GetPath() + @"\tmp.jpg";
            modFunction.saveImgTmp(this.Panel1, modFunction.imgPrn);
            this.PrintPreviewDialog1.Document = this.PreparePrintDocument();
            if (!Information.IsNothing(this.PrintPreviewDialog1.Document))
            {
                this.PrintPreviewDialog1.WindowState = FormWindowState.Maximized;
                this.PrintPreviewDialog1.ShowDialog();
            }
            File.Delete(modFunction.imgPrn);
        }

        private void Button32_Click(object sender, EventArgs e)
        {
            //frmHelp help = new frmHelp();
            //MyProject.Forms.frmHelp.Show();
        }

        private void Button4_Click(object sender, EventArgs e)
        {
            if (this.tipoImg == 1)
            {
                this.inserisciOggetto("gioc_r", 0, 0);
            }
            else
            {
                this.inserisciOggetto("gioc_r1", 0, 0);
            }
        }

        private void Button4_MouseDown(object sender, MouseEventArgs e)
        {
            if ((this.tipoImg == 2) & (e.Button == MouseButtons.Right))
            {
                this.ind_or++;
                if (this.ind_or == 9)
                {
                    this.ind_or = 1;
                }
                this.Button4.Image = Image.FromFile(modFunction.GetPath() + @"\Img\or" + Conversions.ToString(this.ind_or) + ".gif");
            }
        }

        private void Button5_Click(object sender, EventArgs e)
        {
            if (this.tipoImg == 1)
            {
                this.inserisciOggetto("ostacolo", 0, 0);
            }
            else
            {
                this.inserisciOggetto("ostacolo1", 0, 0);
            }
        }

        private void Button5_MouseDown(object sender, MouseEventArgs e)
        {
            if ((this.tipoImg == 2) & (e.Button == MouseButtons.Right))
            {
                this.ind_ost++;
                if (this.ind_ost == 5)
                {
                    this.ind_ost = 1;
                }
                this.Button5.Image = Image.FromFile(modFunction.GetPath() + @"\Img\ostacolo" + Conversions.ToString(this.ind_ost) + ".gif");
            }
        }

        private void Button6_Click(object sender, EventArgs e)
        {
            if (this.tipoImg == 1)
            {
                this.inserisciOggetto("gioc_b", 0, 0);
            }
            else
            {
                this.inserisciOggetto("gioc_b1", 0, 0);
            }
            this.polyLinea = false;
        }

        private void Button6_MouseDown(object sender, MouseEventArgs e)
        {
            if ((this.tipoImg == 2) & (e.Button == MouseButtons.Right))
            {
                this.ind_ob++;
                if (this.ind_ob == 9)
                {
                    this.ind_ob = 1;
                }
                this.Button6.Image = Image.FromFile(modFunction.GetPath() + @"\Img\ob" + Conversions.ToString(this.ind_ob) + ".gif");
            }
        }

        private void Button7_Click(object sender, EventArgs e)
        {
            if (this.tipoImg == 1)
            {
                this.inserisciOggetto("gioc_g", 0, 0);
            }
            else
            {
                this.inserisciOggetto("gioc_g1", 0, 0);
            }
        }

        private void Button7_MouseDown(object sender, MouseEventArgs e)
        {
            if ((this.tipoImg == 2) & (e.Button == MouseButtons.Right))
            {
                this.ind_og++;
                if (this.ind_og == 9)
                {
                    this.ind_og = 1;
                }
                this.Button7.Image = Image.FromFile(modFunction.GetPath() + @"\Img\og" + Conversions.ToString(this.ind_og) + ".gif");
            }
        }

        private void Button8_Click(object sender, EventArgs e)
        {
            this.inserisciOggetto("pallone", 0, 0);
        }

        private void Button9_Click(object sender, EventArgs e)
        {
            if (this.tipoImg == 1)
            {
                this.inserisciOggetto("cinesino", 0, 0);
            }
            else
            {
                this.inserisciOggetto("cinesino1", 0, 0);
            }
        }

        private void caricaEsercFromFile()
        {
            StreamReader reader = new StreamReader(Conversions.ToString(Operators.ConcatenateObject(Operators.ConcatenateObject(modFunction.GetPath() + @"\Esercitazioni\", this.ListBox1.SelectedItem), ".ese")));
            this.TextBox1.Text = "";
            this.pulisciPanel();
            object obj4 = Strings.Split(reader.ReadToEnd(), "@#@", -1, CompareMethod.Binary);
            int num3 = Information.UBound((Array)obj4, 1);
            for (int i = 0; i <= num3; i++)
            {
                if (!Information.IsNothing(RuntimeHelpers.GetObjectValue(NewLateBinding.LateIndexGet(obj4, new object[] { i }, null))) && (Strings.Right(Conversions.ToString(NewLateBinding.LateIndexGet(obj4, new object[] { i }, null)), Strings.Len(RuntimeHelpers.GetObjectValue(NewLateBinding.LateIndexGet(obj4, new object[] { i }, null))) - 4) != ""))
                {
                    object obj2;
                    object obj5;
                    switch (Strings.Left(Conversions.ToString(NewLateBinding.LateIndexGet(obj4, new object[] { i }, null)), 3))
                    {
                        case "tit":
                            this.Label4.Text = Strings.Right(Conversions.ToString(NewLateBinding.LateIndexGet(obj4, new object[] { i }, null)), Strings.Len(RuntimeHelpers.GetObjectValue(NewLateBinding.LateIndexGet(obj4, new object[] { i }, null))) - 4);
                            break;

                        case "txt":
                            obj2 = Strings.Split(Strings.Right(Conversions.ToString(NewLateBinding.LateIndexGet(obj4, new object[] { i }, null)), Strings.Len(RuntimeHelpers.GetObjectValue(NewLateBinding.LateIndexGet(obj4, new object[] { i }, null))) - 4), "-", -1, CompareMethod.Binary);
                            obj5 = Strings.Split(Conversions.ToString(NewLateBinding.LateIndexGet(obj2, new object[] { 1 }, null)), ",", -1, CompareMethod.Binary);
                            this.inserisciTesto(Conversions.ToString(NewLateBinding.LateIndexGet(obj2, new object[] { 0 }, null)), Conversions.ToInteger(NewLateBinding.LateIndexGet(obj5, new object[] { 0 }, null)), Conversions.ToInteger(NewLateBinding.LateIndexGet(obj5, new object[] { 1 }, null)));
                            break;

                        case "ogg":
                            obj2 = Strings.Split(Strings.Right(Conversions.ToString(NewLateBinding.LateIndexGet(obj4, new object[] { i }, null)), Strings.Len(RuntimeHelpers.GetObjectValue(NewLateBinding.LateIndexGet(obj4, new object[] { i }, null))) - 4), "-", -1, CompareMethod.Binary);
                            obj5 = Strings.Split(Conversions.ToString(NewLateBinding.LateIndexGet(obj2, new object[] { 1 }, null)), ",", -1, CompareMethod.Binary);
                            if (Strings.InStr(Conversions.ToString(NewLateBinding.LateIndexGet(obj2, new object[] { 0 }, null)), "%&%", CompareMethod.Binary) > 0)
                            {
                                object obj3 = Strings.Split(Conversions.ToString(NewLateBinding.LateIndexGet(obj2, new object[] { 0 }, null)), "%&%", -1, CompareMethod.Binary);
                                this.ind_ob = Conversions.ToInteger(NewLateBinding.LateIndexGet(obj3, new object[] { 1 }, null));
                                this.ind_og = Conversions.ToInteger(NewLateBinding.LateIndexGet(obj3, new object[] { 1 }, null));
                                this.ind_or = Conversions.ToInteger(NewLateBinding.LateIndexGet(obj3, new object[] { 1 }, null));
                                this.ind_ost = Conversions.ToInteger(NewLateBinding.LateIndexGet(obj3, new object[] { 1 }, null));
                                this.inserisciOggetto(Conversions.ToString(NewLateBinding.LateIndexGet(obj3, new object[] { 0 }, null)), Conversions.ToInteger(NewLateBinding.LateIndexGet(obj5, new object[] { 0 }, null)), Conversions.ToInteger(NewLateBinding.LateIndexGet(obj5, new object[] { 1 }, null)));
                                this.ind_ob = 1;
                                this.ind_og = 1;
                                this.ind_or = 1;
                                this.ind_ost = 1;
                            }
                            else
                            {
                                this.inserisciOggetto(Conversions.ToString(NewLateBinding.LateIndexGet(obj2, new object[] { 0 }, null)), Conversions.ToInteger(NewLateBinding.LateIndexGet(obj5, new object[] { 0 }, null)), Conversions.ToInteger(NewLateBinding.LateIndexGet(obj5, new object[] { 1 }, null)));
                            }
                            break;

                        case "sfo":
                            this.nomeSfondo = Strings.Right(Conversions.ToString(NewLateBinding.LateIndexGet(obj4, new object[] { i }, null)), Strings.Len(RuntimeHelpers.GetObjectValue(NewLateBinding.LateIndexGet(obj4, new object[] { i }, null))) - 4);
                            this.insSfondo();
                            break;

                        case "pol":
                            {
                                if (this.memPolyLinee[0].x[0] != 0f)
                                {
                                    this.memPolyLinee = (myPolyLinea[])Utils.CopyArray((Array)this.memPolyLinee, new myPolyLinea[(Information.UBound(this.memPolyLinee, 1) + 1) + 1]);
                                    this.memPolyLinee[Information.UBound(this.memPolyLinee, 1)].x = new float[1];
                                    this.memPolyLinee[Information.UBound(this.memPolyLinee, 1)].y = new float[1];
                                }
                                obj2 = Strings.Split(Strings.Right(Conversions.ToString(NewLateBinding.LateIndexGet(obj4, new object[] { i }, null)), Strings.Len(RuntimeHelpers.GetObjectValue(NewLateBinding.LateIndexGet(obj4, new object[] { i }, null))) - 4), ",", -1, CompareMethod.Binary);
                                int num4 = Information.UBound((Array)obj2, 1);
                                for (int j = 0; j <= num4; j++)
                                {
                                    int num5 = Information.UBound(this.memPolyLinee, 1);
                                    if (this.xOy)
                                    {
                                        if (this.memPolyLinee[Information.UBound(this.memPolyLinee, 1)].x[0] != 0f)
                                        {
                                            this.memPolyLinee[Information.UBound(this.memPolyLinee, 1)].x = (float[])Utils.CopyArray((Array)this.memPolyLinee[Information.UBound(this.memPolyLinee, 1)].x, new float[(Information.UBound(this.memPolyLinee[Information.UBound(this.memPolyLinee, 1)].x, 1) + 1) + 1]);
                                            this.memPolyLinee[Information.UBound(this.memPolyLinee, 1)].y = (float[])Utils.CopyArray((Array)this.memPolyLinee[Information.UBound(this.memPolyLinee, 1)].y, new float[(Information.UBound(this.memPolyLinee[Information.UBound(this.memPolyLinee, 1)].y, 1) + 1) + 1]);
                                        }
                                        this.memPolyLinee[Information.UBound(this.memPolyLinee, 1)].x[Information.UBound(this.memPolyLinee[Information.UBound(this.memPolyLinee, 1)].x, 1)] = Conversions.ToSingle(NewLateBinding.LateIndexGet(obj2, new object[] { j }, null));
                                        this.xOy = false;
                                    }
                                    else
                                    {
                                        this.memPolyLinee[Information.UBound(this.memPolyLinee, 1)].y[Information.UBound(this.memPolyLinee[Information.UBound(this.memPolyLinee, 1)].y, 1)] = Conversions.ToSingle(NewLateBinding.LateIndexGet(obj2, new object[] { j }, null));
                                        this.xOy = true;
                                    }
                                }
                                this.printPolyLineaOnForm();
                                break;
                            }
                        case "lin":
                            {
                                if (this.memLinee[0].tipoTrattoLinea != "")
                                {
                                    this.memLinee = (myLinea[])Utils.CopyArray((Array)this.memLinee, new myLinea[(Information.UBound(this.memLinee, 1) + 1) + 1]);
                                }
                                obj2 = Strings.Split(Strings.Right(Conversions.ToString(NewLateBinding.LateIndexGet(obj4, new object[] { i }, null)), Strings.Len(RuntimeHelpers.GetObjectValue(NewLateBinding.LateIndexGet(obj4, new object[] { i }, null))) - 4), ",", -1, CompareMethod.Binary);
                                int index = Information.UBound(this.memLinee, 1);
                                this.memLinee[index].tipoTrattoLinea = Conversions.ToString(NewLateBinding.LateIndexGet(obj2, new object[] { 0 }, null));
                                this.memLinee[index].x1 = Conversions.ToInteger(NewLateBinding.LateIndexGet(obj2, new object[] { 1 }, null));
                                this.memLinee[index].y1 = Conversions.ToInteger(NewLateBinding.LateIndexGet(obj2, new object[] { 2 }, null));
                                this.memLinee[index].x2 = Conversions.ToInteger(NewLateBinding.LateIndexGet(obj2, new object[] { 3 }, null));
                                this.memLinee[index].y2 = Conversions.ToInteger(NewLateBinding.LateIndexGet(obj2, new object[] { 4 }, null));
                                this.printLineaOnForm();
                                break;
                            }
                        case "des":
                            this.TextBox1.Text = Strings.Right(Conversions.ToString(NewLateBinding.LateIndexGet(obj4, new object[] { i }, null)), Strings.Len(RuntimeHelpers.GetObjectValue(NewLateBinding.LateIndexGet(obj4, new object[] { i }, null))) - 4);
                            break;
                    }
                }
            }
            reader.Close();
            modFunction.eseTitolo = this.Label4.Text;
            modFunction.eseDesc = this.TextBox1.Text;
        }

        private void disLinea(Control doveDisegno, float[] p1, float[] p2, [Optional, DefaultParameterValue("solid")] string cheLinea)
        {
            Graphics graphics = doveDisegno.CreateGraphics();
            if (cheLinea == "solid")
            {
                this.colorePenna = Color.Black;
            }
            else if (cheLinea == "dash")
            {
                this.colorePenna = Color.Red;
            }
            Pen pen = new Pen(this.colorePenna, 3f);
            pen.EndCap = LineCap.ArrowAnchor;
            pen.StartCap = LineCap.SquareAnchor;
            if (cheLinea == "solid")
            {
                pen.DashStyle = DashStyle.Solid;
            }
            else if (cheLinea == "dash")
            {
                pen.DashStyle = DashStyle.Dot;
            }
            graphics.DrawLine(pen, p1[0], p1[1], p2[0], p2[1]);
            pen.Dispose();
        }

        private void disPolyLinea(Control doveDisegno, float[] p1, float[] p2)
        {
            this.PennaPoly.EndCap = LineCap.ArrowAnchor;
            this.PennaPoly.StartCap = LineCap.SquareAnchor;
            this.gPoly.DrawLine(this.PennaPoly, p1[0], p1[1], p2[0], p2[1]);
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing && (this.components != null))
            {
                this.components.Dispose();
            }
            base.Dispose(disposing);
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            this.memPolyLinee[Information.UBound(this.memPolyLinee, 1)].x = (float[])Utils.CopyArray((Array)this.memPolyLinee[Information.UBound(this.memPolyLinee, 1)].x, new float[1]);
            this.memPolyLinee[Information.UBound(this.memPolyLinee, 1)].y = (float[])Utils.CopyArray((Array)this.memPolyLinee[Information.UBound(this.memPolyLinee, 1)].y, new float[1]);
            modFunction.caricaEserc(this.ListBox1);
        }

        public void GetAllControls(object Form, ref ArrayList Controls)
        {
            IEnumerator enumerator = null;
            try
            {
                enumerator = ((IEnumerable)NewLateBinding.LateGet(Form, null, "Controls", new object[0], null, null, null)).GetEnumerator();
                while (enumerator.MoveNext())
                {
                    Control current = (Control)enumerator.Current;
                    if (current.Controls.Count > 0)
                    {
                        this.GetAllControls(current, ref Controls);
                    }
                    Controls.Add(current);
                }
            }
            finally
            {
                if (enumerator is IDisposable)
                {
                    (enumerator as IDisposable).Dispose();
                }
            }
        }

        [DllImport("Gdi32", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
        private static extern int GetDeviceCaps(IntPtr hDc, int nIndex);
        [DllImport("user32", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
        private static extern IntPtr GetWindowDC(IntPtr hWnd);
        
      
        private void inserisciOggetto(string cosa, int posX, int posY)
        {
            this.pbSelezionate.CopyTo(this.pbSelezionateApp, 0);
            this.pbSelezionate = new bool[this.pbSelezionate.Length + 1];
            this.pbSelezionateApp.CopyTo(this.pbSelezionate, 0);
            this.pbSelezionateApp = new bool[this.pbSelezionateApp.Length + 1];
            this.pbSelezionate[this.pbSelezionate.Length - 1] = false;
            PictureBox box = new PictureBox();
            switch (cosa)
            {
                case "gioc_b":
                    box.Image = Image.FromFile(modFunction.GetPath() + @"\Img\omino_b_g.gif");
                    box.Width = 0x1b;
                    box.Height = 50;
                    break;

                case "gioc_b1":
                    box.Image = Image.FromFile(modFunction.GetPath() + @"\Img\ob" + Conversions.ToString(this.ind_ob) + ".gif");
                    box.Width = 30;
                    box.Height = 30;
                    box.Name = cosa + "%&%" + Conversions.ToString(this.ind_ob);
                    break;

                case "gioc_g":
                    box.Image = Image.FromFile(modFunction.GetPath() + @"\Img\omino_g_g.gif");
                    box.Width = 0x1b;
                    box.Height = 50;
                    break;

                case "gioc_g1":
                    box.Image = Image.FromFile(modFunction.GetPath() + @"\Img\og" + Conversions.ToString(this.ind_og) + ".gif");
                    box.Width = 30;
                    box.Height = 30;
                    box.Name = cosa + "%&%" + Conversions.ToString(this.ind_og);
                    break;

                case "gioc_r":
                    box.Image = Image.FromFile(modFunction.GetPath() + @"\Img\omino_r_g.gif");
                    box.Width = 0x1b;
                    box.Height = 50;
                    break;

                case "gioc_r1":
                    box.Image = Image.FromFile(modFunction.GetPath() + @"\Img\or" + Conversions.ToString(this.ind_or) + ".gif");
                    box.Width = 30;
                    box.Height = 30;
                    box.Name = cosa + "%&%" + Conversions.ToString(this.ind_or);
                    break;

                case "birillo":
                    box.Image = Image.FromFile(modFunction.GetPath() + @"\Img\birillo.gif");
                    box.Width = 15;
                    box.Height = 0x11;
                    break;

                case "birillo1":
                    box.Image = Image.FromFile(modFunction.GetPath() + @"\Img\birillo1.gif");
                    box.Width = 14;
                    box.Height = 14;
                    break;

                case "ostacolo":
                    box.Image = Image.FromFile(modFunction.GetPath() + @"\Img\ostacolo_g.gif");
                    box.Width = 12;
                    box.Height = 0x20;
                    break;

                case "ostacolo1":
                    box.Image = Image.FromFile(modFunction.GetPath() + @"\Img\ostacolo" + Conversions.ToString(this.ind_ost) + "a.gif");
                    box.Width = 50;
                    box.Height = 50;
                    box.Name = cosa + "%&%" + Conversions.ToString(this.ind_ost);
                    break;

                case "cinesino":
                    box.Image = Image.FromFile(modFunction.GetPath() + @"\Img\cinesino_g.gif");
                    box.Width = 12;
                    box.Height = 5;
                    break;

                case "cinesino1":
                    box.Image = Image.FromFile(modFunction.GetPath() + @"\Img\cinesino1.gif");
                    box.Width = 8;
                    box.Height = 8;
                    break;

                case "paletto":
                    box.Image = Image.FromFile(modFunction.GetPath() + @"\Img\paletto.gif");
                    box.Width = 2;
                    box.Height = 50;
                    break;

                case "paletto1":
                    box.Image = Image.FromFile(modFunction.GetPath() + @"\Img\paletto1.gif");
                    box.Width = 5;
                    box.Height = 5;
                    break;

                case "pallone":
                    box.Image = Image.FromFile(modFunction.GetPath() + @"\Img\palla_g.gif");
                    box.Width = 15;
                    box.Height = 15;
                    break;
            }
            if (box.Name == "")
            {
                box.Name = cosa;
            }
            box.Left = posX;
            box.Top = posY;
            this.Panel1.Controls.Add(box);
            box.MouseDown += new MouseEventHandler(this.pbOggetto_MouseDown);
            box.MouseUp += new MouseEventHandler(this.pbOggetto_MouseUp);
            box.MouseMove += new MouseEventHandler(this.pbOggetto_MouseMove);
            box.DoubleClick += new EventHandler(this.pbOggetto_DoubleClick);
        }

        private void inserisciTesto(string testoTxt, int posX, int posY)
        {
            if (testoTxt == "")
            {
                testoTxt = Interaction.InputBox("Testo da inserire", "Inserisci", "", -1, -1);
            }
            this.pbSelezionate.CopyTo(this.pbSelezionateApp, 0);
            this.pbSelezionate = new bool[this.pbSelezionate.Length + 1];
            this.pbSelezionateApp.CopyTo(this.pbSelezionate, 0);
            this.pbSelezionateApp = new bool[this.pbSelezionateApp.Length + 1];
            this.pbSelezionate[this.pbSelezionate.Length - 1] = false;
            Label label = new Label();
            label.Left = posX;
            label.Top = posY;
            this.Panel1.Controls.Add(label);
            label.Text = testoTxt;
            label.AutoSize = true;
            label.Name = "testo";
            label.MouseDown += new MouseEventHandler(this.pbOggetto_MouseDown);
            label.MouseUp += new MouseEventHandler(this.pbOggetto_MouseUp);
            label.MouseMove += new MouseEventHandler(this.pbOggetto_MouseMove);
            label.DoubleClick += new EventHandler(this.pbOggetto_DoubleClick);
        }

        private void insSfondo()
        {
            this.Panel1.BackgroundImage = Image.FromFile(modFunction.GetPath() + @"\Img\" + this.nomeSfondo);
        }

        private void ListBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            this.caricaEsercFromFile();
        }

        private void Panel1_MouseDown(object sender, MouseEventArgs e)
        {
            if (this.linea)
            {
                if (this.clik_linea == 1)
                {
                    this.pointLinea1[0] = e.X;
                    this.pointLinea1[1] = e.Y;
                    this.clik_linea = 2;
                }
                else if (this.clik_linea == 2)
                {
                    this.pointLinea2[0] = e.X;
                    this.pointLinea2[1] = e.Y;
                    if (this.memLinee[0].tipoTrattoLinea == null)
                    {
                        this.memLinee = (myLinea[])Utils.CopyArray((Array)this.memLinee, new myLinea[(Information.UBound(this.memLinee, 1) + 1) + 1]);
                    }
                    this.memLinee[Information.UBound(this.memLinee, 1)].tipoTrattoLinea = this.tipoLinea;
                    this.memLinee[Information.UBound(this.memLinee, 1)].x1 = (int)Math.Round((double)this.pointLinea1[0]);
                    this.memLinee[Information.UBound(this.memLinee, 1)].y1 = (int)Math.Round((double)this.pointLinea1[1]);
                    this.memLinee[Information.UBound(this.memLinee, 1)].x2 = (int)Math.Round((double)this.pointLinea2[0]);
                    this.memLinee[Information.UBound(this.memLinee, 1)].y2 = (int)Math.Round((double)this.pointLinea2[1]);
                    this.disLinea(this.Panel1, this.pointLinea1, this.pointLinea2, this.tipoLinea);
                    this.Panel1.Cursor = Cursors.Default;
                    this.clik_linea = 1;
                    this.linea = false;
                }
            }
            if (this.polyLinea)
            {
                this.polyMouseDown = true;
                this.pStartPoly[0] = e.X;
                this.pStartPoly[1] = e.Y;
                if (Information.UBound(this.memPolyLinee[0].x, 1) != 0)
                {
                    this.memPolyLinee = (myPolyLinea[])Utils.CopyArray((Array)this.memPolyLinee, new myPolyLinea[(Information.UBound(this.memPolyLinee, 1) + 1) + 1]);
                    this.memPolyLinee[Information.UBound(this.memPolyLinee, 1)].x = (float[])Utils.CopyArray((Array)this.memPolyLinee[Information.UBound(this.memPolyLinee, 1)].x, new float[1]);
                    this.memPolyLinee[Information.UBound(this.memPolyLinee, 1)].y = (float[])Utils.CopyArray((Array)this.memPolyLinee[Information.UBound(this.memPolyLinee, 1)].y, new float[1]);
                }
                this.memPolyLinee[Information.UBound(this.memPolyLinee, 1)].x[Information.UBound(this.memPolyLinee[Information.UBound(this.memPolyLinee, 1)].x, 1)] = this.pStartPoly[0];
                this.memPolyLinee[Information.UBound(this.memPolyLinee, 1)].y[Information.UBound(this.memPolyLinee[Information.UBound(this.memPolyLinee, 1)].y, 1)] = this.pStartPoly[1];
            }
        }

        private void Panel1_MouseMove(object sender, MouseEventArgs e)
        {
            this.Label1.Text = Conversions.ToString(Math.Round((double)(((double)e.X) / 5.5)) - 2.0) + "," + Conversions.ToString(Math.Round((double)(((double)e.Y) / 7.0)) - 1.0);
            if (this.polyMouseDown)
            {
                this.contator += 1L;
                float[] numArray = new float[] { (float)e.X, (float)e.Y };
                this.memPolyLinee[Information.UBound(this.memPolyLinee, 1)].x = (float[])Utils.CopyArray((Array)this.memPolyLinee[Information.UBound(this.memPolyLinee, 1)].x, new float[(Information.UBound(this.memPolyLinee[Information.UBound(this.memPolyLinee, 1)].x, 1) + 1) + 1]);
                this.memPolyLinee[Information.UBound(this.memPolyLinee, 1)].y = (float[])Utils.CopyArray((Array)this.memPolyLinee[Information.UBound(this.memPolyLinee, 1)].y, new float[(Information.UBound(this.memPolyLinee[Information.UBound(this.memPolyLinee, 1)].y, 1) + 1) + 1]);
                this.memPolyLinee[Information.UBound(this.memPolyLinee, 1)].x[Information.UBound(this.memPolyLinee[Information.UBound(this.memPolyLinee, 1)].x, 1)] = numArray[0];
                this.memPolyLinee[Information.UBound(this.memPolyLinee, 1)].y[Information.UBound(this.memPolyLinee[Information.UBound(this.memPolyLinee, 1)].y, 1)] = numArray[1];
                Console.WriteLine(Conversions.ToString(this.memPolyLinee[Information.UBound(this.memPolyLinee, 1)].x[Information.UBound(this.memPolyLinee[Information.UBound(this.memPolyLinee, 1)].x, 1)]) + "," + Conversions.ToString(this.memPolyLinee[Information.UBound(this.memPolyLinee, 1)].y[Information.UBound(this.memPolyLinee[Information.UBound(this.memPolyLinee, 1)].y, 1)]));
                if (this.startPoly)
                {
                    this.disPolyLinea(this.Panel1, this.pStartPoly, numArray);
                    this.startPoly = false;
                }
                else
                {
                    this.disPolyLinea(this.Panel1, this.oldPolyPoint, numArray);
                }
                this.oldPolyPoint[0] = numArray[0];
                this.oldPolyPoint[1] = numArray[1];
            }
        }

        private void Panel1_MouseUp(object sender, MouseEventArgs e)
        {
            if (this.polyMouseDown)
            {
                this.Panel1.Cursor = Cursors.Default;
            }
            this.polyLinea = false;
            this.polyMouseDown = false;
            Console.WriteLine(this.contator);
            this.contator = 0L;
        }

        private void Panel1_Paint(object sender, PaintEventArgs e)
        {
            this.printLineaOnForm();
            this.printPolyLineaOnForm();
        }

        public string ParseTextBox(int RowLen, string RowText)
        {
            string find = "\r\n";
            string str = "\x0014";
            string expression = Strings.Replace(RowText, find, " ", 1, -1, CompareMethod.Binary);
            expression = Strings.Replace(RowText, str, " ", 1, -1, CompareMethod.Binary);
            string str5 = "";
            int num = 0;
            while (Strings.Len(expression) > 0)
            {
                if (Strings.Len(expression) < RowLen)
                {
                    return (str5 + find + expression);
                }
                if (RowLen <= num)
                {
                    return str5;
                }
                string str6 = Strings.Mid(expression, 1, RowLen - num);
                if (Strings.Right(str6, 1) != " ")
                {
                    num++;
                }
                else
                {
                    str5 = str5 + find + str6;
                    expression = Strings.Mid(expression, RowLen - num);
                    num = 0;
                }
            }
            return str5;
        }

        private void pbOggetto_DoubleClick(object sender, EventArgs e)
        {
            if (this.pbSelezionate[this.Panel1.Controls.IndexOf((Control)sender)])
            {
                NewLateBinding.LateSet(sender, null, "BorderStyle", new object[] { BorderStyle.None }, null, null);
                this.pbSelezionate[this.Panel1.Controls.IndexOf((Control)sender)] = false;
            }
            else
            {
                NewLateBinding.LateSet(sender, null, "BorderStyle", new object[] { BorderStyle.FixedSingle }, null, null);
                this.pbSelezionate[this.Panel1.Controls.IndexOf((Control)sender)] = true;
                this.Label1.Text = Conversions.ToString(this.Panel1.Controls.IndexOf((Control)sender));
            }
        }

        private void pbOggetto_MouseDown(object sender, MouseEventArgs e)
        {
            this.presoPB = true;
            this.pbX = e.X;
            this.pbY = e.Y;
        }

        private void pbOggetto_MouseMove(object sender, MouseEventArgs e)
        {
            if (this.presoPB)
            {
                if ((((Control.MousePosition.X - this.Left) - this.Panel1.Left) - this.pbX) < 0)
                {
                    NewLateBinding.LateSet(sender, null, "Left", new object[] { 0 }, null, null);
                }
                else if (Operators.ConditionalCompareObjectGreater(((Control.MousePosition.X - this.Left) - this.Panel1.Left) - this.pbX, Operators.SubtractObject(this.Panel1.Width, NewLateBinding.LateGet(sender, null, "Width", new object[0], null, null, null)), false))
                {
                    NewLateBinding.LateSet(sender, null, "Left", new object[] { Operators.SubtractObject(this.Panel1.Width, NewLateBinding.LateGet(sender, null, "Width", new object[0], null, null, null)) }, null, null);
                }
                else
                {
                    NewLateBinding.LateSet(sender, null, "Left", new object[] { (((Control.MousePosition.X - this.Left) - this.Panel1.Left) - this.pbX) - 6 }, null, null);
                }
                if (((((Control.MousePosition.Y - this.Top) - this.Panel1.Top) - SystemInformation.CaptionHeight) - this.pbY) < 0)
                {
                    NewLateBinding.LateSet(sender, null, "Top", new object[] { 0 }, null, null);
                }
                else if (Operators.ConditionalCompareObjectGreater((((Control.MousePosition.Y - this.Top) - this.Panel1.Top) - SystemInformation.CaptionHeight) - this.pbY, Operators.SubtractObject(this.Panel1.Height, NewLateBinding.LateGet(sender, null, "Height", new object[0], null, null, null)), false))
                {
                    NewLateBinding.LateSet(sender, null, "Top", new object[] { Operators.SubtractObject(this.Panel1.Height, NewLateBinding.LateGet(sender, null, "Height", new object[0], null, null, null)) }, null, null);
                }
                else
                {
                    NewLateBinding.LateSet(sender, null, "Top", new object[] { ((((Control.MousePosition.Y - this.Top) - this.Panel1.Top) - SystemInformation.CaptionHeight) - this.pbY) - 6 }, null, null);
                }
            }
        }

        private void pbOggetto_MouseUp(object sender, MouseEventArgs e)
        {
            this.presoPB = false;
        }

        private void PictureBox1_MouseDown(object sender, MouseEventArgs e)
        {
            this.presoPB = true;
            this.pbX = e.X;
            this.pbY = e.Y;
        }

        private void PictureBox1_MouseUp(object sender, MouseEventArgs e)
        {
            this.presoPB = false;
        }

        private PrintDocument PreparePrintDocument()
        {
            this.print_document.DocumentName = "Esercitazione";
            this.print_document.DefaultPageSettings.Landscape = false;
            this.print_document.PrintPage += new PrintPageEventHandler(this.Print_PrintPage);
            this.print_document.BeginPrint += new PrintEventHandler(this.Print_BeginPrint);
            return this.print_document;
        }

        private void Print_BeginPrint(object sender, PrintEventArgs e)
        {
            if (this.anteprimaStampa)
            {
                this.stampa = true;
                this.anteprimaStampa = false;
            }
            else
            {
                this.anteprimaStampa = true;
            }
        }

        private void Print_PrintPage(object sender, PrintPageEventArgs e)
        {
            double num = -1;
            double num3 = -1;
            double num5 = -1;
            double num7 = -1;
            this.trovaMargini(e, ref num3, ref num7, ref num5, ref num);
            float num8 = (float)((num7 / 0.025399999693036079) + 10.0);
            float num4 = (float)((num3 / 0.025399999693036079) + 10.0);
            float num2 = (float)((num / 0.025399999693036079) + 10.0);
            float num6 = (float)((num5 / 0.025399999693036079) + 10.0);
            this.stampaEsercitazione(e, (double)num4, (double)num8, (double)num6, num);
        }

        private void printLineaOnForm()
        {
            float[] numArray = new float[2];
            float[] numArray2 = new float[2];
            int num2 = Information.UBound(this.memLinee, 1);
            for (int i = 0; i <= num2; i++)
            {
                numArray[0] = this.memLinee[i].x1;
                numArray[1] = this.memLinee[i].y1;
                numArray2[0] = this.memLinee[i].x2;
                numArray2[1] = this.memLinee[i].y2;
                this.disLinea(this.Panel1, numArray, numArray2, this.memLinee[i].tipoTrattoLinea);
            }
        }

        private void printPolyLineaOnForm()
        {
            long num;
            float[] numArray = new float[2];
            long num3 = Information.UBound(this.memPolyLinee, 1);
            for (num = 0L; num <= num3; num += 1L)
            {
                this.gPoly = this.Panel1.CreateGraphics();
                long num4 = Information.UBound(this.memPolyLinee[(int)num].x, 1);
                long num2 = 0L;
                while (num2 <= num4)
                {
                    if (num2 == 0L)
                    {
                        this.pStartPoly[0] = this.memPolyLinee[(int)num].x[(int)num2];
                        this.pStartPoly[1] = this.memPolyLinee[(int)num].y[(int)num2];
                    }
                    else
                    {
                        numArray[0] = this.memPolyLinee[(int)num].x[(int)num2];
                        numArray[1] = this.memPolyLinee[(int)num].y[(int)num2];
                        this.disPolyLinea(this.Panel1, this.pStartPoly, numArray);
                        this.pStartPoly[0] = this.memPolyLinee[(int)num].x[(int)num2];
                        this.pStartPoly[1] = this.memPolyLinee[(int)num].y[(int)num2];
                    }
                    num2 += 1L;
                }
                num2 = 0L;
            }
            num = 0L;
        }

        private void PrintPreviewDialog1_Closing(object sender, CancelEventArgs e)
        {
            this.anteprimaStampa = false;
            this.print_document = new PrintDocument();
        }

        private void pulisciPanel()
        {
            int num2 = this.Panel1.Controls.Count - 1;
            for (int i = 0; i <= num2; i++)
            {
                this.Panel1.Controls.RemoveAt(0);
            }
            this.Panel1.BackgroundImage = null;
            this.nomeSfondo = "";
            this.memLinee = new myLinea[1];
            int index = 0;
            this.memLinee[index].tipoTrattoLinea = "";
            this.memLinee[index].x1 = 0;
            this.memLinee[index].x2 = 0;
            this.memLinee[index].y1 = 0;
            this.memLinee[index].y2 = 0;
            this.memPolyLinee = new myPolyLinea[1];
            this.memPolyLinee[0].x = new float[1];
            this.memPolyLinee[0].y = new float[1];
            this.memLinee = new myLinea[1];
            this.memPolyLinee = new myPolyLinea[1];
            this.memPolyLinee[0].x = new float[1];
            this.memPolyLinee[0].y = new float[1];
            this.Panel1.Visible = false;
            this.Panel1.Visible = true;
        }

        [DllImport("user32", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
        private static extern IntPtr ReleaseDC(IntPtr hWnd, IntPtr hDc);
        public void SalvaPannello(Panel pannello, string fileName)
        {
            SaveFileDialog dialog = new SaveFileDialog();
            Bitmap image = new Bitmap(pannello.Width, pannello.Height);
            Graphics graphics = Graphics.FromImage(image);
            IntPtr windowDC = GetWindowDC(pannello.Handle);
            IntPtr hdc = graphics.GetHdc();
            BitBlt(hdc, 0, 0, this.Size.Width, this.Size.Height, windowDC, 0, 0, 0xcc0020);
            ReleaseDC(this.Panel1.Handle, windowDC);
            graphics.ReleaseHdc(hdc);
            graphics.Dispose();
            dialog.Filter = "jpg files (*.jpg)|*.jpg";
            if (dialog.ShowDialog() == DialogResult.OK)
            {
                string filename = dialog.FileName;
                image.Save(filename, ImageFormat.Jpeg);
            }
        }

        [DllImport("kernel32", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
        private static extern void Sleep(long dwMilliseconds);
        private void stampaEsercitazione(PrintPageEventArgs e, double leftMarginAreaIn, double topMarginAreaIn, double rightMarginAreaIn, double bottomMarginAreaIn)
        {
            int num2;
            int num3;
            if (this.stampa)
            {
                num2 = (int)Math.Round(leftMarginAreaIn);
                num3 = (int)Math.Round(topMarginAreaIn);
            }
            else
            {
                num2 = 0;
                num3 = 0;
            }
            FontStyle regular = FontStyle.Regular;
            FontStyle style2 = FontStyle.Underline | FontStyle.Bold;
            FontStyle italic = FontStyle.Italic;
            Font font2 = new Font("Arial", 12f, style2);
            Font font3 = new Font("Arial", 11f, regular);
            Font font = new Font("Arial", 10f, italic);
            SolidBrush brush = new SolidBrush(Color.Black);
            StringFormat format = new StringFormat();
            int num4 = (int)Math.Round((double)(leftMarginAreaIn - num2));
            int num5 = (int)Math.Round((double)(topMarginAreaIn - num3));
            double num7 = (e.PageSettings.Bounds.Size.Width - leftMarginAreaIn) - rightMarginAreaIn;
            double num = (e.PageSettings.Bounds.Size.Height - topMarginAreaIn) - bottomMarginAreaIn;
            Pen pen = new Pen(Color.Black);
            pen.DashStyle = DashStyle.Solid;
            int num6 = (int)Math.Round((double)font.GetHeight(e.Graphics));
            RectangleF layoutRectangle = new RectangleF(80f, 50f, 650f, 30f);
            string text = this.Label4.Text;
            e.Graphics.DrawString(text, font2, brush, layoutRectangle);
            Image image = Image.FromFile(modFunction.imgPrn);
            Rectangle rect = new Rectangle(80, 80, 500, 0x160);
            e.Graphics.DrawImage(image, rect);
            RectangleF ef2 = new RectangleF(80f, 440f, 650f, 20f);
            text = "Descrizione";
            e.Graphics.DrawString(text, font3, brush, ef2);
            RectangleF ef = new RectangleF(80f, 460f, 650f, 352f);
            text = this.TextBox1.Text;
            e.Graphics.DrawString(text, font, brush, ef);
            e.HasMorePages = false;
            font2.Dispose();
            font3.Dispose();
            font.Dispose();
            brush.Dispose();
            image.Dispose();
            e.Graphics.Dispose();
        }

        private void trovaMargini(PrintPageEventArgs e, ref double leftMarginArea, ref double topMarginArea, ref double rightMarginArea, ref double bottomMarginArea)
        {
            int num3 = (int)Math.Round((double)e.Graphics.DpiX);
            int num4 = (int)Math.Round((double)e.Graphics.DpiY);
            IntPtr hdc = e.Graphics.GetHdc();
            leftMarginArea = (((double)(GetDeviceCaps(hdc, 0x70) * 100)) / ((double)num3)) * 0.025399999693036079;
            topMarginArea = (((double)(GetDeviceCaps(hdc, 0x71) * 100)) / ((double)num4)) * 0.025399999693036079;
            float num2 = (float)(((double)GetDeviceCaps(hdc, 4)) / 10.0);
            float num = (float)(((double)GetDeviceCaps(hdc, 6)) / 10.0);
            e.Graphics.ReleaseHdc(hdc);
            rightMarginArea = ((e.PageBounds.Width * 0.0254f) - num2) - leftMarginArea;
            bottomMarginArea = ((e.PageBounds.Height * 0.0254f) - num) - topMarginArea;
            e.PageSettings.Margins.Left = (int)Math.Round(leftMarginArea);
            e.PageSettings.Margins.Top = (int)Math.Round(topMarginArea);
            e.PageSettings.Margins.Right = (int)Math.Round(rightMarginArea);
            e.PageSettings.Margins.Bottom = (int)Math.Round(bottomMarginArea);
        }

        public string UpCase(string frase)
        {
            string[] array = Strings.Split(frase, " ", -1, CompareMethod.Binary);
            int num2 = Information.UBound(array, 1);
            for (int i = 0; i <= num2; i++)
            {
                array[i] = Strings.UCase(Strings.Mid(Conversions.ToString(frase[i]), 1, 1));
                Strings.LCase(Strings.Mid(Conversions.ToString(frase[i]), 2));
            }
            return Strings.Join(array, " ");
        }

        // Properties
        internal virtual Button Button1
        {
            get
            {
                return this._Button1;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                if (this._Button1 != null)
                {
                    this._Button1.Click -= new EventHandler(this.Button1_Click);
                }
                this._Button1 = value;
                if (this._Button1 != null)
                {
                    this._Button1.Click += new EventHandler(this.Button1_Click);
                }
            }
        }

        internal virtual Button Button10
        {
            get
            {
                return this._Button10;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                if (this._Button10 != null)
                {
                    this._Button10.Click -= new EventHandler(this.Button10_Click);
                }
                this._Button10 = value;
                if (this._Button10 != null)
                {
                    this._Button10.Click += new EventHandler(this.Button10_Click);
                }
            }
        }

        internal virtual Button Button11
        {
            get
            {
                return this._Button11;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                if (this._Button11 != null)
                {
                    this._Button11.Click -= new EventHandler(this.Button11_Click);
                }
                this._Button11 = value;
                if (this._Button11 != null)
                {
                    this._Button11.Click += new EventHandler(this.Button11_Click);
                }
            }
        }

        internal virtual Button Button12
        {
            get
            {
                return this._Button12;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                if (this._Button12 != null)
                {
                    this._Button12.Click -= new EventHandler(this.Button12_Click);
                }
                this._Button12 = value;
                if (this._Button12 != null)
                {
                    this._Button12.Click += new EventHandler(this.Button12_Click);
                }
            }
        }

        internal virtual Button Button13
        {
            get
            {
                return this._Button13;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                if (this._Button13 != null)
                {
                    this._Button13.Click -= new EventHandler(this.Button13_Click);
                }
                this._Button13 = value;
                if (this._Button13 != null)
                {
                    this._Button13.Click += new EventHandler(this.Button13_Click);
                }
            }
        }

        internal virtual Button Button14
        {
            get
            {
                return this._Button14;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                if (this._Button14 != null)
                {
                    this._Button14.Click -= new EventHandler(this.Button14_Click);
                }
                this._Button14 = value;
                if (this._Button14 != null)
                {
                    this._Button14.Click += new EventHandler(this.Button14_Click);
                }
            }
        }

        internal virtual Button Button15
        {
            get
            {
                return this._Button15;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                if (this._Button15 != null)
                {
                    this._Button15.Click -= new EventHandler(this.Button15_Click);
                }
                this._Button15 = value;
                if (this._Button15 != null)
                {
                    this._Button15.Click += new EventHandler(this.Button15_Click);
                }
            }
        }

        internal virtual Button Button16
        {
            get
            {
                return this._Button16;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                if (this._Button16 != null)
                {
                    this._Button16.Click -= new EventHandler(this.Button16_Click);
                }
                this._Button16 = value;
                if (this._Button16 != null)
                {
                    this._Button16.Click += new EventHandler(this.Button16_Click);
                }
            }
        }

        internal virtual Button Button17
        {
            get
            {
                return this._Button17;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                if (this._Button17 != null)
                {
                    this._Button17.Click -= new EventHandler(this.Button17_Click);
                }
                this._Button17 = value;
                if (this._Button17 != null)
                {
                    this._Button17.Click += new EventHandler(this.Button17_Click);
                }
            }
        }

        internal virtual Button Button18
        {
            get
            {
                return this._Button18;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                if (this._Button18 != null)
                {
                    this._Button18.Click -= new EventHandler(this.Button18_Click);
                }
                this._Button18 = value;
                if (this._Button18 != null)
                {
                    this._Button18.Click += new EventHandler(this.Button18_Click);
                }
            }
        }

        internal virtual Button Button19
        {
            get
            {
                return this._Button19;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                if (this._Button19 != null)
                {
                    this._Button19.Click -= new EventHandler(this.Button19_Click);
                }
                this._Button19 = value;
                if (this._Button19 != null)
                {
                    this._Button19.Click += new EventHandler(this.Button19_Click);
                }
            }
        }

        internal virtual Button Button2
        {
            get
            {
                return this._Button2;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                if (this._Button2 != null)
                {
                    this._Button2.Click -= new EventHandler(this.Button2_Click);
                }
                this._Button2 = value;
                if (this._Button2 != null)
                {
                    this._Button2.Click += new EventHandler(this.Button2_Click);
                }
            }
        }

        internal virtual Button Button20
        {
            get
            {
                return this._Button20;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                if (this._Button20 != null)
                {
                    this._Button20.Click -= new EventHandler(this.Button20_Click);
                }
                this._Button20 = value;
                if (this._Button20 != null)
                {
                    this._Button20.Click += new EventHandler(this.Button20_Click);
                }
            }
        }

        internal virtual Button Button21
        {
            get
            {
                return this._Button21;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                if (this._Button21 != null)
                {
                    this._Button21.Click -= new EventHandler(this.Button21_Click);
                }
                this._Button21 = value;
                if (this._Button21 != null)
                {
                    this._Button21.Click += new EventHandler(this.Button21_Click);
                }
            }
        }

        internal virtual Button Button22
        {
            get
            {
                return this._Button22;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                if (this._Button22 != null)
                {
                    this._Button22.Click -= new EventHandler(this.Button22_Click);
                }
                this._Button22 = value;
                if (this._Button22 != null)
                {
                    this._Button22.Click += new EventHandler(this.Button22_Click);
                }
            }
        }

        internal virtual Button Button23
        {
            get
            {
                return this._Button23;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                if (this._Button23 != null)
                {
                    this._Button23.Click -= new EventHandler(this.Button23_Click);
                }
                this._Button23 = value;
                if (this._Button23 != null)
                {
                    this._Button23.Click += new EventHandler(this.Button23_Click);
                }
            }
        }

        internal virtual Button Button24
        {
            get
            {
                return this._Button24;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                if (this._Button24 != null)
                {
                    this._Button24.Click -= new EventHandler(this.Button24_Click);
                }
                this._Button24 = value;
                if (this._Button24 != null)
                {
                    this._Button24.Click += new EventHandler(this.Button24_Click);
                }
            }
        }

        internal virtual Button Button25
        {
            get
            {
                return this._Button25;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                if (this._Button25 != null)
                {
                    this._Button25.Click -= new EventHandler(this.Button25_Click);
                }
                this._Button25 = value;
                if (this._Button25 != null)
                {
                    this._Button25.Click += new EventHandler(this.Button25_Click);
                }
            }
        }

        internal virtual Button Button26
        {
            get
            {
                return this._Button26;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                if (this._Button26 != null)
                {
                    this._Button26.Click -= new EventHandler(this.Button26_Click);
                }
                this._Button26 = value;
                if (this._Button26 != null)
                {
                    this._Button26.Click += new EventHandler(this.Button26_Click);
                }
            }
        }

        internal virtual Button Button27
        {
            get
            {
                return this._Button27;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                if (this._Button27 != null)
                {
                    this._Button27.Click -= new EventHandler(this.Button27_Click);
                }
                this._Button27 = value;
                if (this._Button27 != null)
                {
                    this._Button27.Click += new EventHandler(this.Button27_Click);
                }
            }
        }

        internal virtual Button Button28
        {
            get
            {
                return this._Button28;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                if (this._Button28 != null)
                {
                    this._Button28.Click -= new EventHandler(this.Button28_Click);
                }
                this._Button28 = value;
                if (this._Button28 != null)
                {
                    this._Button28.Click += new EventHandler(this.Button28_Click);
                }
            }
        }

        internal virtual Button Button29
        {
            get
            {
                return this._Button29;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                if (this._Button29 != null)
                {
                    this._Button29.Click -= new EventHandler(this.Button29_Click);
                }
                this._Button29 = value;
                if (this._Button29 != null)
                {
                    this._Button29.Click += new EventHandler(this.Button29_Click);
                }
            }
        }

        internal virtual Button Button3
        {
            get
            {
                return this._Button3;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                if (this._Button3 != null)
                {
                    this._Button3.Click -= new EventHandler(this.Button3_Click);
                }
                this._Button3 = value;
                if (this._Button3 != null)
                {
                    this._Button3.Click += new EventHandler(this.Button3_Click);
                }
            }
        }

        internal virtual Button Button30
        {
            get
            {
                return this._Button30;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                if (this._Button30 != null)
                {
                    this._Button30.Click -= new EventHandler(this.Button30_Click);
                }
                this._Button30 = value;
                if (this._Button30 != null)
                {
                    this._Button30.Click += new EventHandler(this.Button30_Click);
                }
            }
        }

        internal virtual Button Button31
        {
            get
            {
                return this._Button31;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                if (this._Button31 != null)
                {
                    this._Button31.Click -= new EventHandler(this.Button31_Click);
                }
                this._Button31 = value;
                if (this._Button31 != null)
                {
                    this._Button31.Click += new EventHandler(this.Button31_Click);
                }
            }
        }

        internal virtual Button Button32
        {
            get
            {
                return this._Button32;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                if (this._Button32 != null)
                {
                    this._Button32.Click -= new EventHandler(this.Button32_Click);
                }
                this._Button32 = value;
                if (this._Button32 != null)
                {
                    this._Button32.Click += new EventHandler(this.Button32_Click);
                }
            }
        }

        internal virtual Button Button4
        {
            get
            {
                return this._Button4;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                if (this._Button4 != null)
                {
                    this._Button4.Click -= new EventHandler(this.Button4_Click);
                    this._Button4.MouseDown -= new MouseEventHandler(this.Button4_MouseDown);
                }
                this._Button4 = value;
                if (this._Button4 != null)
                {
                    this._Button4.Click += new EventHandler(this.Button4_Click);
                    this._Button4.MouseDown += new MouseEventHandler(this.Button4_MouseDown);
                }
            }
        }

        internal virtual Button Button5
        {
            get
            {
                return this._Button5;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                if (this._Button5 != null)
                {
                    this._Button5.Click -= new EventHandler(this.Button5_Click);
                    this._Button5.MouseDown -= new MouseEventHandler(this.Button5_MouseDown);
                }
                this._Button5 = value;
                if (this._Button5 != null)
                {
                    this._Button5.Click += new EventHandler(this.Button5_Click);
                    this._Button5.MouseDown += new MouseEventHandler(this.Button5_MouseDown);
                }
            }
        }

        internal virtual Button Button6
        {
            get
            {
                return this._Button6;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                if (this._Button6 != null)
                {
                    this._Button6.Click -= new EventHandler(this.Button6_Click);
                    this._Button6.MouseDown -= new MouseEventHandler(this.Button6_MouseDown);
                }
                this._Button6 = value;
                if (this._Button6 != null)
                {
                    this._Button6.Click += new EventHandler(this.Button6_Click);
                    this._Button6.MouseDown += new MouseEventHandler(this.Button6_MouseDown);
                }
            }
        }

        internal virtual Button Button7
        {
            get
            {
                return this._Button7;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                if (this._Button7 != null)
                {
                    this._Button7.Click -= new EventHandler(this.Button7_Click);
                    this._Button7.MouseDown -= new MouseEventHandler(this.Button7_MouseDown);
                }
                this._Button7 = value;
                if (this._Button7 != null)
                {
                    this._Button7.Click += new EventHandler(this.Button7_Click);
                    this._Button7.MouseDown += new MouseEventHandler(this.Button7_MouseDown);
                }
            }
        }

        internal virtual Button Button8
        {
            get
            {
                return this._Button8;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                if (this._Button8 != null)
                {
                    this._Button8.Click -= new EventHandler(this.Button8_Click);
                }
                this._Button8 = value;
                if (this._Button8 != null)
                {
                    this._Button8.Click += new EventHandler(this.Button8_Click);
                }
            }
        }

        internal virtual Button Button9
        {
            get
            {
                return this._Button9;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                if (this._Button9 != null)
                {
                    this._Button9.Click -= new EventHandler(this.Button9_Click);
                }
                this._Button9 = value;
                if (this._Button9 != null)
                {
                    this._Button9.Click += new EventHandler(this.Button9_Click);
                }
            }
        }

        internal virtual Label Label1
        {
            get
            {
                return this._Label1;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                this._Label1 = value;
            }
        }

        internal virtual Label Label2
        {
            get
            {
                return this._Label2;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                this._Label2 = value;
            }
        }

        internal virtual Label Label3
        {
            get
            {
                return this._Label3;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                this._Label3 = value;
            }
        }

        internal virtual Label Label4
        {
            get
            {
                return this._Label4;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                this._Label4 = value;
            }
        }

        internal virtual Label Label6
        {
            get
            {
                return this._Label6;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                this._Label6 = value;
            }
        }

        internal virtual ListBox ListBox1
        {
            get
            {
                return this._ListBox1;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                if (this._ListBox1 != null)
                {
                    this._ListBox1.SelectedIndexChanged -= new EventHandler(this.ListBox1_SelectedIndexChanged);
                }
                this._ListBox1 = value;
                if (this._ListBox1 != null)
                {
                    this._ListBox1.SelectedIndexChanged += new EventHandler(this.ListBox1_SelectedIndexChanged);
                }
            }
        }

        internal virtual Panel Panel1
        {
            get
            {
                return this._Panel1;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                if (this._Panel1 != null)
                {
                    this._Panel1.MouseUp -= new MouseEventHandler(this.Panel1_MouseUp);
                    this._Panel1.MouseMove -= new MouseEventHandler(this.Panel1_MouseMove);
                    this._Panel1.MouseDown -= new MouseEventHandler(this.Panel1_MouseDown);
                    this._Panel1.Paint -= new PaintEventHandler(this.Panel1_Paint);
                }
                this._Panel1 = value;
                if (this._Panel1 != null)
                {
                    this._Panel1.MouseUp += new MouseEventHandler(this.Panel1_MouseUp);
                    this._Panel1.MouseMove += new MouseEventHandler(this.Panel1_MouseMove);
                    this._Panel1.MouseDown += new MouseEventHandler(this.Panel1_MouseDown);
                    this._Panel1.Paint += new PaintEventHandler(this.Panel1_Paint);
                }
            }
        }

        internal virtual PrintPreviewDialog PrintPreviewDialog1
        {
            get
            {
                return this._PrintPreviewDialog1;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                if (this._PrintPreviewDialog1 != null)
                {
                    this._PrintPreviewDialog1.Closing -= new CancelEventHandler(this.PrintPreviewDialog1_Closing);
                }
                this._PrintPreviewDialog1 = value;
                if (this._PrintPreviewDialog1 != null)
                {
                    this._PrintPreviewDialog1.Closing += new CancelEventHandler(this.PrintPreviewDialog1_Closing);
                }
            }
        }

        internal virtual SaveFileDialog SaveFileDialog1
        {
            get
            {
                return this._SaveFileDialog1;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                this._SaveFileDialog1 = value;
            }
        }

        internal virtual TextBox TextBox1
        {
            get
            {
                return this._TextBox1;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                this._TextBox1 = value;
            }
        }

        // Nested Types
        [StructLayout(LayoutKind.Sequential)]
        public struct myLinea
        {
            public string tipoTrattoLinea;
            public int x1;
            public int y1;
            public int x2;
            public int y2;
        }

        [StructLayout(LayoutKind.Sequential)]
        public struct myPolyLinea
        {
            public float[] x;
            public float[] y;
        }
    }

}
